package com.plian.system.wrapper.hr.staff;

import com.plian.Tools.DateUtil;
import com.plian.system.dto.hr.staff.StaffFilesDTO;
import com.plian.system.entity.hr.staff.StaffFiles;
import com.plian.system.mybatis.support.BaseWrapper;
import com.plian.system.vo.hr.staff.StaffFilesVO;
import com.plian.system.vo.zzd.sys.PersonnelSimpleInfoVO;
import com.plian.system.wrapper.util.CacheWrapperUtil;
import com.plian.system.wrapper.util.WrapperUtil;
import org.mapstruct.Mapper;
import org.mapstruct.Mapping;
import org.mapstruct.Mappings;

import java.util.List;

import static com.plian.system.wrapper.util.WrapperConstant.*;

/**
 * 员工档案包装类,返回视图层所需的字段
 *
 * @author gangan
 * @since 2019-09-29
 */
@Mapper(componentModel = SPRING, uses = {CacheWrapperUtil.class, WrapperUtil.class})
public interface StaffFilesWrapper extends BaseWrapper<StaffFiles, StaffFilesDTO, StaffFilesVO> {

	@Override
	@Mappings(value = {
			@Mapping(source = "createUser", target = "createUserName", qualifiedByName = USER_ID_TO_NAME),
			@Mapping(source = "approvedUser", target = "approvedUserName", qualifiedByName = USER_ID_TO_NAME),
			@Mapping(source = "companyNameId", target = "companyName", qualifiedByName = ORG_ID_TO_NAME),
			@Mapping(source = "companyNameId", target = "companyCode", qualifiedByName = ORG_ID_TO_CODE),
			@Mapping(source = "documentTypeId", target = "documentTypeName", qualifiedByName = DICT_CODE_TO_NAME),
			@Mapping(source = "genderId", target = "genderName", qualifiedByName = DICT_CODE_TO_NAME),
			@Mapping(source = "nationId", target = "nationName", qualifiedByName = DICT_CODE_TO_NAME),
			@Mapping(source = "politicCountenanceId", target = "politicCountenanceName", qualifiedByName = DICT_CODE_TO_NAME),
			@Mapping(source = "nationalityId", target = "nationalityName", qualifiedByName = DICT_CODE_TO_NAME),
			@Mapping(source = "maritalStatusId", target = "maritalStatusName", qualifiedByName = DICT_CODE_TO_NAME),
			@Mapping(source = "educationalId", target = "educationalName", qualifiedByName = DICT_CODE_TO_NAME),
			@Mapping(source = "degreeId", target = "degreeName", qualifiedByName = DICT_CODE_TO_NAME),
			@Mapping(source = "managementCategoryId", target = "managementCategoryName", qualifiedByName = DICT_CODE_TO_NAME),
			@Mapping(source = "compilationTypeId", target = "compilationTypeName", qualifiedByName = DICT_CODE_TO_NAME),
			@Mapping(source = "jobCategoryId", target = "jobCategoryName", qualifiedByName = DICT_CODE_TO_NAME),
			@Mapping(source = "rankId", target = "rankName", qualifiedByName = DICT_CODE_TO_NAME),
			@Mapping(source = "changeEventsId", target = "changeEventsName", qualifiedByName = DICT_CODE_TO_NAME),
			@Mapping(source = "changeTypeId", target = "changeTypeName", qualifiedByName = DICT_CODE_TO_NAME),
			@Mapping(source = "healthConditionId", target = "healthConditionName", qualifiedByName = DICT_CODE_TO_NAME),
			@Mapping(source = "departmentNameId", target = "departmentName", qualifiedByName = DEPT_STR_ID_TO_NAME),
			@Mapping(source = "jobNameId", target = "jobNameId", qualifiedByName = STR_NULL_TO_EMPTY),
			@Mapping(source = "jobNameId", target = "jobNameName", defaultValue = ""),
			@Mapping(source = "birthday", target = "birthdayStr", dateFormat = DateUtil.PATTERN_DATE_POINT),
			@Mapping(source = "joinPartyTime", target = "joinPartyTimeStr", dateFormat = DateUtil.PATTERN_MONTH_POINT),
			@Mapping(source = "changeTime", target = "changeTimeStr", dateFormat = DateUtil.PATTERN_MONTH_POINT),
			@Mapping(source = "changeDateTime", target = "changeDateTimeStr", dateFormat = DateUtil.PATTERN_MONTH_POINT),
			@Mapping(source = "approvedTime", target = "approvedTimeStr", dateFormat = DateUtil.PATTERN_MONTH_POINT),
			@Mapping(source = "staffCode", target = "staffCode", qualifiedByName = DECRYPT_BASE64_DATA),
			@Mapping(source = "documentNumber", target = "documentNumber", qualifiedByName = DECRYPT_BASE64_DATA)
	})
	StaffFilesVO entityToVO(StaffFiles entity);


	@Mappings(value = {
			@Mapping(source = "jobNameId", target = "jobName")
	})
	PersonnelSimpleInfoVO entityToPersonnelSimpleInfoVO(StaffFiles entity);

	List<PersonnelSimpleInfoVO> entityToPersonnelSimpleInfoVO(List<StaffFiles> entityList);
}
